package org.paterczm.watermarker;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class Options {

	private ArrayList<Profile> profiles = new ArrayList<Profile>();

	private String inputDirectory = "input dir", outputDirectory = "output dir";

	public static void main(String[] args) {
		try {
			Options.loadOptions("options.xml");
		} catch (FileNotFoundException e) {
			try {
				Options o = new Options();
				o.getProfiles().add(new Profile("profile1"));
				o.saveOptions("options.xml");
			} catch (IOException e1) {
				e1.printStackTrace();
				System.exit(1);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public static Options loadOptions(String fileName) throws IOException {
		XStream xstream = new XStream(new DomDriver());

		FileReader fr = new FileReader(fileName);
		Options ret = (Options) xstream.fromXML(fr);
		fr.close();
		return ret;
	}

	public void saveOptions(String fileName) throws IOException {
		XStream xstream = new XStream(new DomDriver());

		FileWriter w = new FileWriter(fileName);
		xstream.toXML(this, w);
		w.close();
	}

	public ArrayList<Profile> getProfiles() {
		return profiles;
	}

	public void setProfiles(ArrayList<Profile> profiles) {
		this.profiles = profiles;
	}

	public String getInputDirectory() {
		return inputDirectory;
	}

	public void setInputDirectory(String inputDirectory) {
		this.inputDirectory = inputDirectory;
	}

	public String getOutputDirectory() {
		return outputDirectory;
	}

	public void setOutputDirectory(String outputDirectory) {
		this.outputDirectory = outputDirectory;
	}
}
